package com.meitianhui.convenitenbuy.module.store.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meitianhui.convenitenbuy.R;
import com.meitianhui.convenitenbuy.module.store.model.StoreInfo;
import com.meitianhui.convenitenbuy.util.GlideUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/22.
 */

public class StoreAdapter extends BaseQuickAdapter<StoreInfo.Convenient, BaseViewHolder> {
    private Context mContext;
    private Map<String, String> mUrlMap;

    public StoreAdapter(Context context, @Nullable List<StoreInfo.Convenient> data, Map<String, String> urlMap) {
        super(R.layout.item_store, data);
        mContext = context;
        mUrlMap = urlMap;
    }

    @Override
    protected void convert(BaseViewHolder helper, StoreInfo.Convenient item) {

        helper.setText(R.id.tv_store_name, item.getStores_name());
        helper.setText(R.id.tv_location, item.getAddress());
        helper.setText(R.id.tv_distance, item.getDistance() + "米");
        String url = mUrlMap.get(item.getNeighbor_pic_path());
        Log.d("map", mUrlMap.size() + "");
        GlideUtils.setRectImage(mContext, url, R.mipmap.icon_default_picture, R.mipmap.icon_default_picture, helper.getView(R.id.iv_store));

    }

    public void setNewData(List data, Map<String, String> map) {
        setNewData(data);
        this.mUrlMap = map;
    }

    public void addData(List data, Map<String, String> map) {
        addData(data);
        mUrlMap.putAll(map);
    }
}
